package com.china08.yxyapi.service.mg.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.china08.yxyapi.entity.mg.statistics.SchoolUploadResourceReport;
import com.china08.yxyapi.repository.mg.SchoolUploadResourceReportRepository;
import com.china08.yxyapi.service.mg.ResourceCountSchoolListService;
@Service
public class ResourceCountSchoolListServiceImpl implements ResourceCountSchoolListService {
	   @Autowired
	   private SchoolUploadResourceReportRepository schoolUploadResourceReportRepository;
	
	  /**
	   * 获取地区
	   */
      @Override
      public Page<SchoolUploadResourceReport> getAreaContent(String districtCode,String cityName,String areaName,String phaseName,String schoolName,String listOrder,Pageable pageable){
    	  Page<SchoolUploadResourceReport> schoolUploadResourceReportLst=null;
    	  if (schoolName!=null && !schoolName.equals("")) {//如果学校不为空
      		schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndSchoolNickLike(districtCode,schoolName,pageable);
				if (phaseName!=null && !phaseName.equals("")) {//如果学校不为空和学段不为空
					schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLike(districtCode,phaseName,schoolName,pageable);
					if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和学段不为空和列表排序不为空
						   if (listOrder.equals("资源总数从高到低")) {	
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLikeOrderByResCountDesc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源总数从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLikeOrderByResCountAsc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从高到低")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLikeOrderByShareResCountDesc(districtCode,phaseName,schoolName,pageable); 
						   }
						   if (listOrder.equals("资源共享从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInAndSchoolNickLikeOrderByShareResCountAsc(districtCode,phaseName,schoolName,pageable); 
						   }
					}
				}else
				if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和列表排序不为空
					   if (listOrder.equals("资源总数从高到低")) {	
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndSchoolNickLikeOrderByResCountDesc(districtCode,schoolName,pageable); 
					   }
					   if (listOrder.equals("资源总数从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndSchoolNickLikeOrderByResCountAsc(districtCode,schoolName,pageable); 
					   }
					   if (listOrder.equals("资源共享从高到低")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndSchoolNickLikeOrderByShareResCountDesc(districtCode,schoolName,pageable);
					   }
					   if (listOrder.equals("资源共享从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndSchoolNickLikeOrderByShareResCountAsc(districtCode,schoolName,pageable);
					   }
				}
			}else{//如果学校为空
				if (phaseName!=null && !phaseName.equals("")) {//如果学校为空和学段不为空
					schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageIn(districtCode,phaseName,pageable);
					if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和学段不为空和列表排序不为空
						   if (listOrder.equals("资源总数从高到低")) {	
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInOrderByResCountDesc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("资源总数从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInOrderByResCountAsc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("资源共享从高到低")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInOrderByShareResCountDesc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("资源共享从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictAndStageInOrderByShareResCountAsc(districtCode,phaseName,pageable);
						   }
					}
				}else
				if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和列表排序不为空
					   if (listOrder.equals("资源总数从高到低")) {	
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictOrderByResCountDesc(districtCode,pageable);
					   }
					   if (listOrder.equals("资源总数从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictOrderByResCountAsc(districtCode,pageable);
					   }
					   if (listOrder.equals("资源共享从高到低")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictOrderByShareResCountDesc(districtCode,pageable);
					   }
					   if (listOrder.equals("资源共享从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictOrderByShareResCountAsc(districtCode,pageable);
					   }
				}
			}
    	  if (schoolUploadResourceReportLst==null) {			
    		  schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdDistrictOrderByResCountDesc(districtCode,pageable);
		  }
	    return schoolUploadResourceReportLst;
      }
      /**
	   * 获取市
	   */
      @Override
      public Page<SchoolUploadResourceReport> getCityContent(String districtCode,String cityName,String areaName,String phaseName,String schoolName,String listOrder,Pageable pageable){
    	  Page<SchoolUploadResourceReport> schoolUploadResourceReportLst=null;
      if (schoolName!=null && !schoolName.equals("")) {//如果学校不为空
			schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndSchoolNickLike(districtCode,schoolName,pageable);
//		   if (cityName!=null&&!cityName.equals("")) {//如果城市不为空和学校不为空
			
			   if (areaName!=null && !areaName.equals("")) {//如果区县不为空和学校不为空
				   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLike(districtCode,areaName,schoolName,pageable);
				  if(phaseName!=null && !phaseName.equals("")){//如果学段不为空和区县不为空和学校不为空
					  schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLike(districtCode,areaName,phaseName,schoolName,pageable);
					  
					   if(listOrder!=null && !listOrder.equals("")){//如果列表排序不为空和学段不为空和区县不为空和学校不为空
						   
						   
						   if (listOrder.equals("资源总数从高到低")) {	//如果列表排序是资源总数从高到低，   和学段不为空和区县不为空和学校不为空							   
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByResCountDesc(districtCode,areaName,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源总数从低到高")) {//如果列表排序是资源总数从低到高，   和学段不为空和区县不为空和学校不为空
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByResCountAsc(districtCode,areaName,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从高到低")) {//如果列表排序是资源共享从高到低，   和学段不为空和区县不为空和学校不为空
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareResCountDesc(districtCode,areaName,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从低到高")) {//如果列表排序是资源共享从低到高，   和学段不为空和区县不为空和学校不为空
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareResCountAsc(districtCode,areaName,phaseName,schoolName,pageable);
						   }
					   }
					   
				  }else
				  if(listOrder!=null && !listOrder.equals("")){//如果区县不为空和学校不为空列表排序不为空
					   if (listOrder.equals("资源总数从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLikeOrderByResCountDesc(districtCode,areaName,schoolName,pageable);
					   }
					   if (listOrder.equals("资源总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLikeOrderByResCountAsc(districtCode,areaName,schoolName,pageable);
					   }
					   if (listOrder.equals("资源共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLikeOrderByShareResCountDesc(districtCode,areaName,schoolName,pageable);
					   }
					   if (listOrder.equals("资源共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndSchoolNickLikeOrderByShareResCountAsc(districtCode,areaName,schoolName,pageable);
					   }
					   
				  }
			   }else
			   if(listOrder!=null && !listOrder.equals("")){//如果学校不为空和列表排序不为空
				   
				   if (listOrder.equals("资源总数从高到低")) {
					   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndSchoolNickLikeOrderByResCountDesc(districtCode,schoolName,pageable);
				   }
				   if (listOrder.equals("资源总数从低到高")) {
					   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndSchoolNickLikeOrderByResCountAsc(districtCode,schoolName,pageable);
				   }
				   if (listOrder.equals("资源共享从高到低")) {
					   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndSchoolNickLikeOrderByShareResCountDesc(districtCode,schoolName,pageable);
				   }
				   if (listOrder.equals("资源共享从低到高")) {
					   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndSchoolNickLikeOrderByShareResCountAsc(districtCode,schoolName,pageable);
				   }
			   }
//		   }
		}else{//如果没有学校的模糊查询
//			if (cityName!=null&&!cityName.equals("")) {//如果学校为空
				
				   if (areaName!=null && !areaName.equals("")) {//如果区县不为空和学校为空
					   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrict(districtCode,areaName,pageable);
					  if(phaseName!=null && !phaseName.equals("")){//如果学段不为空和区县不为空和学校为空
						  schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageIn(districtCode,areaName,phaseName,pageable);
						   if(listOrder!=null && !listOrder.equals("")){//如果列表排序不为空和学段不为空和区县不为空和学校为空
							   if (listOrder.equals("资源总数从高到低")) {						   
								   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInOrderByResCountDesc(districtCode,areaName,phaseName,pageable);
							   }
							   if (listOrder.equals("资源总数从低到高")) {
								   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInOrderByResCountAsc(districtCode,areaName,phaseName,pageable);
							   }
							   if (listOrder.equals("资源共享从高到低")) {
								   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInOrderByShareResCountDesc(districtCode,areaName,phaseName,pageable);
							   }
							   if (listOrder.equals("资源共享从低到高")) {
								   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictAndStageInOrderByShareResCountAsc(districtCode,areaName,phaseName,pageable);
							   }
						   }
					  }else{
						  if(listOrder!=null && !listOrder.equals("")){//如果列表排序不为空和学段为空和区县不为空和学校为空
							   if (listOrder.equals("资源总数从高到低")) {						   
								   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictOrderByResCountDesc(districtCode,areaName,pageable);
							   }
							   if (listOrder.equals("资源总数从低到高")) {
								   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictOrderByResCountAsc(districtCode,areaName,pageable);
							   }
							   if (listOrder.equals("资源共享从高到低")) {
								   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictOrderByShareResCountDesc(districtCode,areaName,pageable);
							   }
							   if (listOrder.equals("资源共享从低到高")) {
								   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndAreaNameDistrictOrderByShareResCountAsc(districtCode,areaName,pageable);
							   }
						   }
					  }
				   }else
				   if(phaseName!=null && !phaseName.equals("")){//如果学段不为空和学校为空
					   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByStageInAndAreaIdCity(phaseName,districtCode,pageable);
					   if(listOrder!=null && !listOrder.equals("")){//如果学段不为空和列表排序不为空和学校为空
						   if (listOrder.equals("资源总数从高到低")) {	
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndStageInOrderByResCountDesc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("资源总数从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndStageInOrderByResCountAsc(districtCode,phaseName,pageable);
						   }
						   if (listOrder.equals("资源共享从高到低")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndStageInOrderByShareResCountDesc(districtCode,phaseName,pageable); 
						   }
						   if (listOrder.equals("资源共享从低到高")) {
							   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityAndStageInOrderByShareResCountAsc(districtCode,phaseName,pageable); 
						   }
					   }
				   }else
//			   }
			   if(listOrder!=null && !listOrder.equals("")){//如果学校为空和列表排序不为空
				   if (listOrder.equals("资源总数从高到低")) {						   
					   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityOrderByResCountDesc(districtCode,pageable);
				   }
				   if (listOrder.equals("资源总数从低到高")) {
					   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityOrderByResCountAsc(districtCode,pageable);
				   }
				   if (listOrder.equals("资源共享从高到低")) {
					   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityOrderByShareResCountDesc(districtCode,pageable);
				   }
				   if (listOrder.equals("资源共享从低到高")) {
					   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityOrderByShareResCountAsc(districtCode,pageable);
				   }
			   }
		}
        if (schoolUploadResourceReportLst==null) {			
        	schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdCityOrderByResCountDesc(districtCode,pageable);
		}
        return schoolUploadResourceReportLst;
      }
      /**
	   * 获取省
	   */
      @Override
      public Page<SchoolUploadResourceReport> getProvinceContent(String districtCode,String cityName,String areaName,String phaseName,String schoolName,String listOrder,Pageable pageable){
    	  Page<SchoolUploadResourceReport> schoolUploadResourceReportLst=null;
    	  if (schoolName!=null && !schoolName.equals("")) {//如果学校不为空
				schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndSchoolNickLike(districtCode,schoolName,pageable);
				if (cityName!=null && !cityName.equals("")) {//如果学校不为空和城市不为空
					schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLike(districtCode,cityName,schoolName,pageable);
					if (areaName!=null && !areaName.equals("")) {//如果学校不为空和城市不为空和区县不为空
						schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLike(districtCode,cityName,areaName,schoolName,pageable);
						if (phaseName!=null && !phaseName.equals("")) {//如果学校不为空和城市不为空和区县不为空和学段不为空
							schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLike(districtCode,cityName,areaName,phaseName,schoolName,pageable);	
							if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和城市不为空和区县不为空和学段不为空和列表排序不为空
								   if (listOrder.equals("资源总数从高到低")) {	
									   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByResCountDesc(districtCode,cityName,areaName,phaseName,schoolName,pageable);
								   }
								   if (listOrder.equals("资源总数从低到高")) {
									   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByResCountAsc(districtCode,cityName,areaName,phaseName,schoolName,pageable);  
								   }
								   if (listOrder.equals("资源共享从高到低")) {
									   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareResCountDesc(districtCode,cityName,areaName,phaseName,schoolName,pageable);
								   }
								   if (listOrder.equals("资源共享从低到高")) {
									   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareResCountAsc(districtCode,cityName,areaName,phaseName,schoolName,pageable);
								   }
							}
						}else
						if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和城市不为空和区县不为空和列表排序不为空
							   if (listOrder.equals("资源总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLikeOrderByResCountDesc(districtCode,cityName,areaName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLikeOrderByResCountAsc(districtCode,cityName,areaName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLikeOrderByShareResCountDesc(districtCode,cityName,areaName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndSchoolNickLikeOrderByShareResCountAsc(districtCode,cityName,areaName,schoolName,pageable);
							   }
						}
					}else if(cityName!=null && !cityName.equals("") && phaseName!=null && !phaseName.equals("")){//市和学段和学校不为空
						schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLike(districtCode,cityName,phaseName,schoolName,pageable);
						if (listOrder!=null && !listOrder.equals("")) {//如果区和学校和列表排序不为空
							   if (listOrder.equals("资源总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLikeOrderByResCountDesc(districtCode,cityName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLikeOrderByResCountAsc(districtCode,cityName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLikeOrderByShareResCountDesc(districtCode,cityName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInAndSchoolNickLikeOrderByShareResCountAsc(districtCode,cityName,phaseName,schoolName,pageable);
							   }
						 }
					}else
					    if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和城市不为空和列表排序不为空
						   if (listOrder.equals("资源总数从高到低")) {	
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLikeOrderByResCountDesc(districtCode,cityName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源总数从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLikeOrderByResCountAsc(districtCode,cityName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从高到低")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLikeOrderByShareResCountDesc(districtCode,cityName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndSchoolNickLikeOrderByShareResCountAsc(districtCode,cityName,schoolName,pageable);
						   }
					   }
					
				}else  if (areaName!=null && !areaName.equals("")){//区和学校不为空
					schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLike(districtCode,areaName,schoolName,pageable);
					if (areaName!=null && !areaName.equals("") && phaseName!=null && !phaseName.equals("")) {
						schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLike(districtCode,areaName,phaseName,schoolName,pageable);
						if (listOrder!=null && !listOrder.equals("")) {//如果区和学校和列表排序不为空
							   if (listOrder.equals("资源总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByResCountDesc(districtCode,areaName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByResCountAsc(districtCode,areaName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareResCountDesc(districtCode,areaName,phaseName,schoolName,pageable);
							   }
							   if (listOrder.equals("资源共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInAndSchoolNickLikeOrderByShareResCountAsc(districtCode,areaName,phaseName,schoolName,pageable);
							   }
						 }
					}else
					if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和区和列表排序不为空
						   if (listOrder.equals("资源总数从高到低")) {	
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLikeOrderByResCountDesc(districtCode,areaName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源总数从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLikeOrderByResCountAsc(districtCode,areaName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从高到低")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLikeOrderByShareResCountDesc(districtCode,areaName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndSchoolNickLikeOrderByShareResCountAsc(districtCode,areaName,schoolName,pageable);
						   }
					 }
				}else if(phaseName!=null && !phaseName.equals("")){//学段和学校不为空
					schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLike(districtCode,phaseName,schoolName,pageable);	
					if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和学段和列表排序不为空
						   if (listOrder.equals("资源总数从高到低")) {	
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLikeOrderByResCountDesc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源总数从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLikeOrderByResCountAsc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从高到低")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLikeOrderByShareResCountDesc(districtCode,phaseName,schoolName,pageable);
						   }
						   if (listOrder.equals("资源共享从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInAndSchoolNickLikeOrderByShareResCountAsc(districtCode,phaseName,schoolName,pageable);
						   }
					 }
				}else 
				if (listOrder!=null && !listOrder.equals("")) {//如果学校不为空和列表排序不为空
					   if (listOrder.equals("资源总数从高到低")) {	
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndSchoolNickLikeOrderByResCountDesc(districtCode,schoolName,pageable);
					   }
					   if (listOrder.equals("资源总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndSchoolNickLikeOrderByResCountAsc(districtCode,schoolName,pageable);
					   }
					   if (listOrder.equals("资源共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndSchoolNickLikeOrderByShareResCountDesc(districtCode,schoolName,pageable);
					   }
					   if (listOrder.equals("资源共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndSchoolNickLikeOrderByShareResCountAsc(districtCode,schoolName,pageable);
					   }
				 }
			}else{//如果学校为空
				if (cityName!=null && !cityName.equals("")) {//如果学校为空和城市不为空
					schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCity(districtCode,cityName,pageable);
					if (areaName!=null && !areaName.equals("")) {//如果学校为空和城市不为空和区县不为空
						schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrict(districtCode,cityName,areaName,pageable);
						if (phaseName!=null && !phaseName.equals("")) {//如果学校为空和城市不为空和区县不为空和学段不为空
							schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageIn(districtCode,cityName,areaName,phaseName,pageable);
							if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和城市不为空和区县不为空和学段不为空和列表排序不为空
								   if (listOrder.equals("资源总数从高到低")) {	
									   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInOrderByResCountDesc(districtCode,cityName,areaName,phaseName,pageable);   
								   }
								   if (listOrder.equals("资源总数从低到高")) {
									   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInOrderByResCountAsc(districtCode,cityName,areaName,phaseName,pageable); 
								   }
								   if (listOrder.equals("资源共享从高到低")) {
									   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInOrderByShareResCountDesc(districtCode,cityName,areaName,phaseName,pageable); 
								   }
								   if (listOrder.equals("资源共享从低到高")) {
									   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictAndStageInOrderByShareResCountAsc(districtCode,cityName,areaName,phaseName,pageable);
								   }
							}
						}else
						if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和城市不为空和区县不为空和列表排序不为空
							   if (listOrder.equals("资源总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictOrderByResCountDesc(districtCode,cityName,areaName,pageable);
							   }
							   if (listOrder.equals("资源总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictOrderByResCountAsc(districtCode,cityName,areaName,pageable);
							   }
							   if (listOrder.equals("资源共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictOrderByShareResCountDesc(districtCode,cityName,areaName,pageable);
							   }
							   if (listOrder.equals("资源共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndAreaNameDistrictOrderByShareResCountAsc(districtCode,cityName,areaName,pageable);
							   }
						}
					}else if (phaseName!=null && !phaseName.equals("")){//如果学校为空和城市不为空和区县为空和学段不为空
						schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageIn(districtCode,cityName,phaseName,pageable);
						if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和城市不为空和区县为空和学段不为空和列表排序不为空
							   if (listOrder.equals("资源总数从高到低")) {	
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInOrderByResCountDesc(districtCode,cityName,phaseName,pageable);
							   }
							   if (listOrder.equals("资源总数从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInOrderByResCountAsc(districtCode,cityName,phaseName,pageable);
							   }
							   if (listOrder.equals("资源共享从高到低")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInOrderByShareResCountDesc(districtCode,cityName,phaseName,pageable);
							   }
							   if (listOrder.equals("资源共享从低到高")) {
								   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityAndStageInOrderByShareResCountAsc(districtCode,cityName,phaseName,pageable);
							   }
						}
					}else
					if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和城市不为空和列表排序不为空
						   if (listOrder.equals("资源总数从高到低")) {	
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityOrderByResCountDesc(districtCode,cityName,pageable);
						   }
						   if (listOrder.equals("资源总数从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityOrderByResCountAsc(districtCode,cityName,pageable);
						   }
						   if (listOrder.equals("资源共享从高到低")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityOrderByShareResCountDesc(districtCode,cityName,pageable);
						   }
						   if (listOrder.equals("资源共享从低到高")) {
							   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameCityOrderByShareResCountAsc(districtCode,cityName,pageable);
						   }
					}
				}else if (areaName!=null && !areaName.equals("") && phaseName!=null && !phaseName.equals("")){//区和学段不为空
					schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageIn(districtCode,areaName,phaseName,pageable);
					if (listOrder.equals("资源总数从高到低")) {	
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInOrderByResCountDesc(districtCode,areaName,phaseName,pageable);
					   }
					   if (listOrder.equals("资源总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInOrderByResCountAsc(districtCode,areaName,phaseName,pageable);
					   }
					   if (listOrder.equals("资源共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInOrderByShareResCountDesc(districtCode,areaName,phaseName,pageable);
					   }
					   if (listOrder.equals("资源共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictAndStageInOrderByShareResCountAsc(districtCode,areaName,phaseName,pageable);
					   }
				}else if (areaName!=null && !areaName.equals("") && listOrder!=null && !listOrder.equals("")) {//区和排序不为空
					if (listOrder.equals("资源总数从高到低")) {	
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictOrderByResCountDesc(districtCode,areaName,pageable);
					   }
					   if (listOrder.equals("资源总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictOrderByResCountAsc(districtCode,areaName,pageable);
					   }
					   if (listOrder.equals("资源共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictOrderByShareResCountDesc(districtCode,areaName,pageable);
					   }
					   if (listOrder.equals("资源共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceAndAreaNameDistrictOrderByShareResCountAsc(districtCode,areaName,pageable);
					   }
				}else if (phaseName!=null && !phaseName.equals("") && listOrder!=null && !listOrder.equals("")) {//学段和排序不为空
					   if (listOrder.equals("资源总数从高到低")) {	
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInOrderByResCountDesc(districtCode,phaseName,pageable);
					   }
					   if (listOrder.equals("资源总数从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInOrderByResCountAsc(districtCode,phaseName,pageable);  
					   }
					   if (listOrder.equals("资源共享从高到低")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInOrderByShareResCountDesc(districtCode,phaseName,pageable);
					   }
					   if (listOrder.equals("资源共享从低到高")) {
						   schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceAndStageInOrderByShareResCountAsc(districtCode,phaseName,pageable);
					   }
				}else
				if (listOrder!=null && !listOrder.equals("")) {//如果学校为空和列表排序不为空
					   if (listOrder.equals("资源总数从高到低")) {	
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceOrderByResCountDesc(districtCode,pageable);
					   }
					   if (listOrder.equals("资源总数从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceOrderByResCountAsc(districtCode,pageable);
					   }
					   if (listOrder.equals("资源共享从高到低")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceOrderByShareResCountDesc(districtCode,pageable);
					   }
					   if (listOrder.equals("资源共享从低到高")) {
						   schoolUploadResourceReportLst = schoolUploadResourceReportRepository.findByAreaIdProvinceOrderByShareResCountAsc(districtCode,pageable);
					   }
				}
			}
    	  if (schoolUploadResourceReportLst==null) {			
    		  schoolUploadResourceReportLst=schoolUploadResourceReportRepository.findByAreaIdProvinceOrderByResCountDesc(districtCode,pageable);
		   }
    	  return schoolUploadResourceReportLst;
      }
}
